import java.util.Scanner;

public class main_704 {

    public static class Solution {
        public int search(int[] nums, int target) {
            int left = 0, right = nums.length - 1;
            while (left <= right) {
                int mid = (right - left) / 2 + left;
                int num = nums[mid];
                if (num == target) {
                    return mid;
                } else if (num > target) {
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            return -1;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("输入数组长度: ");
        int n = scanner.nextInt();

        int[] nums = new int[n];
        System.out.println("输入各个元素: ");
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }

        System.out.print("输入target: ");
        int target = scanner.nextInt();
        Solution solution = new Solution();
        int result = solution.search(nums, target);

        System.out.println("结果: " + result);
        scanner.close();
    }
}
